<?php
/**
 * @package    panel
 * @subpackage panel.environment
 */
/**
 * Configured smarty for CP environment
 * @author Dmitry Bakaleinik (code)
 */
class panel__template {

	protected $smarty;
	protected $template;

	public function __construct() {

		$this->smarty                   = new maf__smarty;
		$this->smarty->template_dir     = PANEL__PATH__TEMPLATES;
		$this->smarty->compile_dir      = PANEL__PATH__CACHE;
		$this->smarty->compile_check    = TRUE;
		$this->smarty->left_delimiter   = "{%";
		$this->smarty->right_delimiter  = "%}";
		$this->smarty->debugging        = FALSE;
		$this->smarty->compile_path_md5 = FALSE;

	}	# Function

	public function __call($_function_, array $_arguments_) {

		return call_user_func_array( array($this->smarty, (string) $_function_), $_arguments_ );

	}	# Function

	/**
	 * @param string $_ Path to template file
	 * @return void
	 */
	public function setTemplate($_) {

		$this->file = (string) $_;

	}	# Function

	public function getTemplate() {

		return $this->file;

	}	# Function

	/**
	 * @throws exception
	 * @return string
	 */
	public function fetchTemplate() {

		try {

			return $this->smarty->fetch( $this->file );

		} catch ( exception $e ) {

			ob_clean();
			throw $e;

		}	# try

	}	# Function

}	# Class

/* EOF */